<html>
<head>
	<title>Test</title>
	
	<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
</head>
<body>
<table>
	<tr>
		<td>Username</td>
		<td><input type="text" name="username" id="username"></td>
	</tr>
	<tr>
		<td>Password</td>
		<td><input type="text" name="password" id="password"></td>
	</tr>
	<tr>
		<td></td>
		<td><input type="button" name="btnAuth" id="btnAuth" value="Authenticate"></td>
	</tr>
</table>

<script type="text/javascript">
	$("#btnAuth").click(function(){

		var username 		= $('#username').val();
		var password		= $('#password').val();

		var data = '{\"userLogin\":\"'+username+'\",\"password\":\"'+password+'\"}';
		
		$.ajax(
			{
				url: "http://localhost:4003/chatws/api/auth/login.html",
				type: 'POST',
			    dataType: 'json',
			    data: data,
			    contentType: 'application/json',
			    mimeType: 'application/json',
				error: function(){
					alert('Quá trình tải dữ liệu bị lỗi');
				},
				beforeSend: function(){},
				complete: function(){},
				success: function(data){
					if (data.error != null) {
						alert(data.error);
					} else {
						alert('Xac thuc thanh cong');
					}
					
				}
			}							
		);
	});
</script>
</body>
</html>